package com.tianjian.myblog.web.admin;

import com.tianjian.myblog.service.BlogService;
import com.tianjian.myblog.vo.BlogQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/admin")
public class BlogController {

    @Autowired
    private BlogService blogService;


    @GetMapping("/blogs")
    public String blogs(@PageableDefault(size = 3,sort = "{updateTime}",direction = Sort.Direction.DESC) Pageable pageable, BlogQuery blog, Model model){


        //model.addAttribute("types",)
        model.addAttribute("page",blogService.listBlog(pageable,blog));
        return "/admin/blogs";
    }
}
